/**
 * Created by Administrator on 2016-12-09.
 */

!function ($) {
    var FASTMC = {
        WEB_ROOT:'/',
        IS_DEBUG   : false,
        ajaxTimeout: 30000,
        statusCode: {ok:200, error:300, timeout:301},
        ui: {
            windowWidth      : 0,
            showSideWidth    : 990,
            sidenavWidth     : 260,
            offsetWidth      : 15,
            displayFirst     : true,
            showSlidebar     : true,      // After the B-JUI initialization, display slidebar
            clientPaging     : true,      // Response paging and sorting information on the client
            overwriteHomeTab : false      // When open an undefined id of navtab, whether overwrite the home navtab
        },
        debug: function(msg) {
            if (this.IS_DEBUG) {
                if (typeof(console) != 'undefined') console.log(msg)
                else alert(msg)
            }
        },
        init: function(options) {
            var op = $.extend({}, options)
            if (op.WEB_ROOT) this.WEB_ROOT = op.WEB_ROOT
            $(window).resize(function() {
                FASTMC.initLayout()
            })
            setTimeout(function() {
                FASTMC.initMainLayout();

            }, 10)
        },
        initMainLayout: function() {
            var ww = $(window).width(),
                hh = $(window).height(),
                th = $('#main-header').height();
            $('#main-navtab .tabsPageContent').height(hh - th);
            FASTMC.initMenu();

        },
        initMenu:function () {
            $("#top-menu>.treeview").unbind();
            $(".popover-menu>ul>li").unbind();
            $("#top-menu>.treeview").hover(function() {
                    var t = $(this),
                        i = t.find(".popover-moreMenu"),
                        r;
                    t.addClass("active");
                    i.length > 0 ? (i.slideDown(150), n(i.find(".treeview>a")[0]).trigger("click")) : (r = t.find(".popover-menu"), r.slideDown(150))
                },
                function() {
                    var t = $(this),
                        r = t.find(".popover-menu"),
                        i = t.find(".popover-moreMenu");
                    i.length == 0 ? r.slideUp(50) : i.hide();
                    t.removeClass("active")
                });

            $(".popover-menu>ul>li").hover(function() {
                    var t = $(this),f;
                    if (t.parents(".moresubmenu").length == 0) {
                        var e = $(window).width(),
                            r = $(window).height(),
                            i = t.find(".popover-menu-sub"),
                            u = i.height();
                        e - t.offset().left - 154 < 152 && i.css("left", "-156px");
                        u - 10 + t.offset().top > r && (f = u - 10 + t.offset().top - r + 46, i.css("margin-top", "-" + f + "px"));
                        t.addClass("active");
                        i.slideDown(150)
                    }
                },
                function() {
                    var t =$(this),i;
                    t.parents(".moresubmenu").length == 0 && (i = t.find(".popover-menu-sub"), t.removeClass("active"), i.css("margin-top", "-46px"), i.slideUp(50))
                });
        }



    }
    window.FASTMC = FASTMC
}(jQuery);


